<?php

namespace app\storeapi\model\resources;
use app\common\model\resources\Course as CourseModel;


/**
 * 课件模型
 * Class User
 * @package app\store\model
 */
class Course extends CourseModel
{
    /**
     * 获取课件列表
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function getList($param)
    {
        $page = isset($param['page']) && is_numeric($param['page']) ? intval($param['page']) : 1;
        $limit = 10;
        $offset = ($page - 1) * $limit;
        return $this->useGlobalScope(false)
            ->with(['image'])
            ->alias('a')
            ->field('a.course_id,a.course_title,a.image_id')
            ->where('is_delete', '=', 0)
            ->order(['course_sort' => 'asc', 'create_time' => 'desc'])
            ->limit($offset, $limit)
            ->select();

    }



    /**
     * 获取课件详情
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function info($param)
    {
        $course_id = $param['course_id'];
        //增加浏览量
        $this->useGlobalScope(false)->where(['course_id'=>$course_id])->setInc('actual_views');
        return $this->useGlobalScope(false)
            ->with(['image'])
            ->where(['course_id'=>$course_id])
            ->find();

    }






}
